package mqtt

import (
	gomqtt "github.com/eclipse/paho.mqtt.golang"
)

// 跟MQTT服务器连接的实例
var client gomqtt.Client

// 初始化监听器
func Init(opts *gomqtt.ClientOptions) (err error) {
	opts.SetOnConnectHandler(onConnectHandler(opts.OnConnect))
	opts.SetConnectionLostHandler(onConnectionLostHandler(opts.OnConnectionLost))
	client, err = GetClient(opts)
	return
}
